package com.lanmaoly.functiont;

public class Person {

    private String name;
    private Integer age;

    public Person() {

    }

    public Person(Integer age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public static void main(String[] args) {
//        PersonFactory personFactory = Person::new;
//        Person person = personFactory.create(19, "小王");
//        System.out.println(person.toString());
        PersonFactory personFactory2 = new PersonFactory() {
            @Override
            public Person create(Integer age, String name) {
                return new Person(age, name);
            }

            @Override
            public Person create() {
                return new Person();
            }
        };
    }
}
